package com.oa.modules.approvalsec1.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oa.modules.approvalsec1.entity.AudioVideoCollectEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 *
 *
 * @author jiangwei
 * @email 785297226@qq.com
 * @date 2021-03-25 11:21:32
 */
@Mapper
public interface AudioVideoCollectDao extends BaseMapper<AudioVideoCollectEntity> {


    /**
     * 查询总条数
     *
     * @author jiangwei
     * @email 785297226@qq.com
     * @date 2021-03-25 11:21:32
     * @Description 查询分页数据
     */
    @Select("<script>SELECT COUNT( 1 ) FROM (" +
            "select t1.*,t2.FILE_TITLE,t2.FILE_CONTENT,t2.FILE_TYPE,t2.FILE_ADDRESS,t2.FILE_COVER FROM audio_video_collect t1 LEFT JOIN audio_video t2 ON t1.audio_video_id = t2.id  " +
            "where 1=1 " +
            "<if test = 'params != null '> "+
            "and t1.`STATUS` = #{params.status} " +
            "<if test='params.createOper != null'>and t1.create_oper = #{params.createOper} </if> " +
            ") </if> TOTAL</script>")
    long findPage(@Param("params") Map<String, Object> params);

    /**
     * 查询分页数据
     *
     * @author jiangwei
     * @email 785297226@qq.com
     * @date 2021-03-25 11:21:32
     * @Description 查询分页数据
     */
    @Select("<script>select t1.*,t2.FILE_TITLE,t2.FILE_CONTENT,t2.FILE_TYPE,t2.FILE_ADDRESS,t2.FILE_COVER FROM audio_video_collect t1 LEFT JOIN audio_video t2 ON t1.audio_video_id = t2.id " +
            "where 1=1 " +
            "and t1.`STATUS` = #{params.status} " +
            "<if test='params.createOper != null'>and t1.create_oper = #{params.createOper} </if> " +
            "ORDER BY t1.CREATE_DATE desc</script>")
    List<AudioVideoCollectEntity> findRecords(IPage<AudioVideoCollectEntity> page, @Param("params") Map<String, Object> params);

}
